Learning Go Programming by Unknown
Author:Unknown
Language: eng
Format: epub, mobi
Publisher: Packt Publishing
Array length and capacity
The built-in len function returns the declared length of an array type. The built-in cap function can be used on an array to return its capacity. For instance, in the following source snippet, the array seven of type [7]string will return 7 as its length and capacity:
func main() { seven := [7]string{"grumpy", "sleepy", "bashful"} fmt.Println(len(seven), cap(seven)) }
For arrays, the cap() function always returns the same value as len(). This is because the maximum capacity of an array value is its declared length. The capacity function is better suited for use with the slice type (discussed later in the chapter).
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Kathy Andrews Collection by Kathy Andrews(11361)
The remains of the day by Kazuo Ishiguro(8433)
Paper Towns by Green John(4826)
Spare by Prince Harry The Duke of Sussex(4817)
Industrial Automation from Scratch: A hands-on guide to using sensors, actuators, PLCs, HMIs, and SCADA to automate industrial processes by Olushola Akande(4657)
The Body: A Guide for Occupants by Bill Bryson(4618)
Machine Learning at Scale with H2O by Gregory Keys | David Whiting(3697)
Be in a Treehouse by Pete Nelson(3662)
Harry Potter and the Goblet Of Fire by J.K. Rowling(3625)
Never by Ken Follett(3563)
Goodbye Paradise(3473)
The Remains of the Day by Kazuo Ishiguro(3153)
Into Thin Air by Jon Krakauer(3142)
The Cellar by Natasha Preston(3085)
The Genius of Japanese Carpentry by Azby Brown(3055)
Fairy Tale by Stephen King(2995)
120 Days of Sodom by Marquis de Sade(2956)
Drawing Shortcuts: Developing Quick Drawing Skills Using Today's Technology by Leggitt Jim(2944)
The Man Who Died Twice by Richard Osman(2830)
